/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('marketplaceintl', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model DescribeSellerInstancesRequest {
  instanceId?: long(name='InstanceId', example='5000002763123'),
  instanceStatus?: string(name='InstanceStatus', example='OPENED'),
  pageIndex?: int32(name='PageIndex', example='1'),
  pageSize?: long(name='PageSize', example='10'),
  userId?: long(name='UserId', example='5322460655123456'),
}

model DescribeSellerInstancesResponseBody = {
  code?: string(name='Code', example='200'),
  count?: long(name='Count', example='10'),
  fatal?: boolean(name='Fatal', description='fatal', example='False'),
  message?: string(name='Message', example='Instance 5723f7ee-952d-411f-94f4-b942a550d9b8 does not exist.'),
  pageNumber?: long(name='PageNumber', example='1'),
  pageSize?: long(name='PageSize', example='10'),
  requestId?: string(name='RequestId', example='A6A33748-D573-593C-A3BC-593E33D68311'),
  result?: [ 
    {
      appInfo?: string(name='AppInfo', example='{\\\\"authUrl\\\\":\\\\"https://marketplace.alibabacloud.com/\\\\"}'),
      chargeType?: int32(name='ChargeType', example='1'),
      commodityCode?: string(name='CommodityCode', example='sgcmgj000356'),
      createdOn?: long(name='CreatedOn', example='1741752000000'),
      hostInfo?: string(name='HostInfo', example='{\\\\"userName\\\\":\\\\"marketplace\\\\"}'),
      info?: string(name='Info', example='{\\\\"userName\\\\":\\\\"marketplace\\\\"}'),
      instanceId?: long(name='InstanceId', example='5000002763123'),
      instanceStatus?: string(name='InstanceStatus', example='OPENED'),
      userId?: long(name='UserId', example='5322460655123456'),
    }
  ](name='Result'),
  success?: boolean(name='Success', example='True'),
  version?: string(name='Version', example='103'),
}

model DescribeSellerInstancesResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: DescribeSellerInstancesResponseBody(name='body'),
}

/**
 * @summary 卖家查询实例列表
 *
 * @param request DescribeSellerInstancesRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return DescribeSellerInstancesResponse
 */
async function describeSellerInstancesWithOptions(request: DescribeSellerInstancesRequest, runtime: Util.RuntimeOptions): DescribeSellerInstancesResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.instanceId)) {
    query['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.instanceStatus)) {
    query['InstanceStatus'] = request.instanceStatus;
  }
  if (!Util.isUnset(request.pageIndex)) {
    query['PageIndex'] = request.pageIndex;
  }
  if (!Util.isUnset(request.pageSize)) {
    query['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.userId)) {
    query['UserId'] = request.userId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeSellerInstances',
    version = '2022-12-30',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 卖家查询实例列表
 *
 * @param request DescribeSellerInstancesRequest
 * @return DescribeSellerInstancesResponse
 */
async function describeSellerInstances(request: DescribeSellerInstancesRequest): DescribeSellerInstancesResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeSellerInstancesWithOptions(request, runtime);
}

model NoticeInstanceUserRequest {
  instanceId?: long(name='InstanceId', example='5000000264872'),
  noticeParam?: string(name='NoticeParam'),
  noticeType?: long(name='NoticeType', example='1'),
}

model NoticeInstanceUserResponseBody = {
  accessDeniedDetail?: {
    authAction?: string(name='AuthAction'),
    authPrincipalDisplayName?: string(name='AuthPrincipalDisplayName'),
    authPrincipalOwnerId?: string(name='AuthPrincipalOwnerId'),
    authPrincipalType?: string(name='AuthPrincipalType'),
    encodedDiagnosticMessage?: string(name='EncodedDiagnosticMessage'),
    noPermissionType?: string(name='NoPermissionType'),
    policyType?: string(name='PolicyType'),
  }(name='AccessDeniedDetail'),
  code?: string(name='Code', example='200'),
  message?: string(name='Message', example='Instance 5723f7ee-952d-411f-94f4-b942a550d9b8 does not exist.'),
  requestId?: string(name='RequestId', example='A6A33748-D573-593C-A3BC-593E33D68311'),
  result?: boolean(name='Result', example='True'),
  success?: boolean(name='Success', example='True'),
}

model NoticeInstanceUserResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: NoticeInstanceUserResponseBody(name='body'),
}

/**
 * @summary isv推送实例消息给用户
 *
 * @param request NoticeInstanceUserRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return NoticeInstanceUserResponse
 */
async function noticeInstanceUserWithOptions(request: NoticeInstanceUserRequest, runtime: Util.RuntimeOptions): NoticeInstanceUserResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.instanceId)) {
    body['InstanceId'] = request.instanceId;
  }
  if (!Util.isUnset(request.noticeParam)) {
    body['NoticeParam'] = request.noticeParam;
  }
  if (!Util.isUnset(request.noticeType)) {
    body['NoticeType'] = request.noticeType;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'NoticeInstanceUser',
    version = '2022-12-30',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary isv推送实例消息给用户
 *
 * @param request NoticeInstanceUserRequest
 * @return NoticeInstanceUserResponse
 */
async function noticeInstanceUser(request: NoticeInstanceUserRequest): NoticeInstanceUserResponse {
  var runtime = new Util.RuntimeOptions{};
  return noticeInstanceUserWithOptions(request, runtime);
}

model PushMeteringDataRequest {
  gmtCreate?: string(name='GmtCreate', example='2023-01-11 10:31:00'),
  meteringData?: [ 
    {
      endTime?: long(name='EndTime', example='1666854480406'),
      instanceId?: string(name='InstanceId', example='gtm-cn-20p314k5h05'),
      meteringAssist?: string(name='MeteringAssist', example='test001'),
      meteringEntity?: string(name='MeteringEntity', example='{"VirtualCpu":10}'),
      startTime?: long(name='StartTime', example='1662284820000'),
    }
  ](name='MeteringData'),
}

model PushMeteringDataResponseBody = {
  code?: string(name='Code', example='200'),
  dynamicMessage?: string(name='DynamicMessage', example='parameter \\\\"service\\\\" can not be blank.'),
  forceFatal?: boolean(name='ForceFatal', example='false'),
  message?: string(name='Message', example='Instance 5723f7ee-952d-411f-94f4-b942a550d9b8 does not exist.'),
  requestId?: string(name='RequestId', example='A6A33748-D573-593C-A3BC-593E33D68311'),
  result?: boolean(name='Result', example='True'),
  success?: boolean(name='Success', example='True'),
}

model PushMeteringDataResponse = {
  headers?: map[string]string(name='headers'),
  statusCode?: int32(name='statusCode'),
  body?: PushMeteringDataResponseBody(name='body'),
}

/**
 * @summary 国际云市场推送计量数据
 *
 * @param request PushMeteringDataRequest
 * @param runtime runtime options for this request RuntimeOptions
 * @return PushMeteringDataResponse
 */
async function pushMeteringDataWithOptions(request: PushMeteringDataRequest, runtime: Util.RuntimeOptions): PushMeteringDataResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.gmtCreate)) {
    body['GmtCreate'] = request.gmtCreate;
  }
  if (!Util.isUnset(request.meteringData)) {
    body['MeteringData'] = request.meteringData;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'PushMeteringData',
    version = '2022-12-30',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  if (Util.isUnset(@signatureVersion) || !Util.equalString(@signatureVersion, 'v4')) {
    return callApi(params, req, runtime);
  } else {
    return execute(params, req, runtime);
  }
}

/**
 * @summary 国际云市场推送计量数据
 *
 * @param request PushMeteringDataRequest
 * @return PushMeteringDataResponse
 */
async function pushMeteringData(request: PushMeteringDataRequest): PushMeteringDataResponse {
  var runtime = new Util.RuntimeOptions{};
  return pushMeteringDataWithOptions(request, runtime);
}

